<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"   
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      >
    <ui:composition template="/secured/template/common/commonLayout.xhtml">
        <ui:define name="commonHeader" />

        <ui:define name="content">
            <h:form id="form">  
                 <CENTER><h1>Service Provider View</h1></CENTER>
                <p:growl id="msg"  />  
                <p:dataTable 
                            id="cars"
                            var="ticket" 
                            value="#{spc.ticketsDispatched}" 
                            paginator="true" 
                            rows="10"  
                            paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"  
                            rowsPerPageTemplate="5,10,15"                               
                            rowKey="#{ticket.idTicket}"  
                            selection="#{spc.spm.selectedTicket}"  
                            selectionMode="single">   
                    
                    <p:ajax event="rowSelect"  listener="#{spc.onRowSelect}" update=":form:display" oncomplete="carDialog.show()" />  
                    <f:facet name="header">  
                        List Tickets available: 
                    </f:facet>                     
                    <p:column id="h">   
                        <f:facet name="header">  
                            List Tickets available: 
                        </f:facet>  
                        <h:outputText value="#{ticket.idTicket}"/> 
                    </p:column>   
                    <p:column id="c1">  
                        <f:facet name="header">  
                            Ticket status
                        </f:facet>  
                        <h:outputText value="#{ticket.status}" />  
                    </p:column>   
                    <p:column id="c2">  
                        <f:facet name="header">  
                            Ticket status
                        </f:facet>  
                        <h:outputText value="#{ticket.startTime}" />   
                    </p:column>                           
                    <p:column id="c3">  
                        <f:facet name="header">  
                            Incident subject
                        </f:facet>  
                        <h:outputText value="#{ticket.incident.incident_subject}" />   
                    </p:column>  
                    <p:column id ="c4">  
                        <f:facet name="header">   
                            Incident degree  
                        </f:facet>  
                        <h:outputText value="#{ticket.incident.incident_degree}" />   
                    </p:column>  
                    <p:column id="c5">  
                        <f:facet name="header">   
                            Incident Time Estimated  
                        </f:facet>  
                        <h:outputText value="#{ticket.incident.incident_time_estimated}" />   
                    </p:column>   

                    <f:facet name="footer">  
                        <p:commandButton id="viewButton" value="View" icon="ui-icon-search"  
                                         oncomplete="carDialog.show()"/>  
                    </f:facet>   

                </p:dataTable>  

                <p:dialog  id ="eventDialog" widgetVar="carDialog" header="Event Details" showEffect="clip" hideEffect="clip" 
                          >    
                    <h:panelGrid id="display" columns="2">   
                        <h:outputText value="Ticket Id:" />  
                        <h:outputText value="#{spc.spm.selectedTicket.idTicket}" />   

                        <h:outputText value="Ticket Status:" />  
                        <h:outputText value="#{spc.spm.selectedTicket.status}" />  

                        <h:outputText value="Ticket starting date:" />  
                        <h:outputText value="#{spc.spm.selectedTicket.startTime}" />                          

                        <h:outputText value="Confirm ticket:" />  
                        <p:selectBooleanCheckbox value="#{spc.spm.value2}">   
                            <p:ajax update="msg" listener="#{spc.spm.addMessage}"/>  
                        </p:selectBooleanCheckbox>  

                        <p:commandButton type="reset" value="Reset" />  
                        <p:commandButton value="Save"  
                                         oncomplete="carDialog.hide()"   
                                         action="#{spc.checkConfirmation}"
                                         />
                    </h:panelGrid>  
                </p:dialog>  
            </h:form>  
        </ui:define> 
        <ui:define name="commonFooter"/>   
    </ui:composition> 
</html>